<?php
/**
 * Created by JetBrains PhpStorm.
 * User: thinhhung
 * Date: 6/5/12
 * Time: 9:08 AM
 * To change this template use File | Settings | File Templates.
 */
//print_r($doanhnghiep);
///echo $doanhnghiep['0']['doanhnghiep']['TENCT'];

App::uses('CakeNumber', 'Utility');
?>
<div id="view">
    <div id="thongtin">
        <div class="head_title"> <p ALIGN="CENTER" style="font-size: xx-large;">HÓA ĐƠN NHẬP HÀNG</p></div>

        <div id="ngày">
            <p align="center">Số : <?php echo $hoadonnhap['HoaDonNhap']['id']; ?>
                | Ngày : <?php echo date('d-m-Y', strtotime($hoadonnhap['HoaDonNhap']['NGAYNHAP'])); ?> </p>
            <br>
        </div>


        <div id="bennhap" style="float: left; margin-left: 3em; font-size: 1.25em">
            <p>Bên nhập : <?php echo $doanhnghiep['0']['doanhnghiep']['TENCT']; ?> </p>

            <p>Địa chỉ : <?php echo $doanhnghiep['0']['doanhnghiep']['DIACHICT']; ?> </p>

            <p>Mã số thuế : <?php echo $doanhnghiep['0']['doanhnghiep']['MSTCT']; ?> </p>
            <br>
        </div>
        <div id="benban" style="float: right; margin-right: 3em; font-size: 1.25em">
            <p>Bên bán : <?php echo $khachhang['0']['KhachHang']['TENKH']; ?></p>

            <p>Địa chỉ : <?php echo $khachhang['0']['KhachHang']['DIACHIKH']; ?></p>


        </div>
    </div>
    <table>
        <tr>
            <th>TÊN HÀNG HÓA</th>
            <th>ĐƠN VỊ TÍNH</th>
            <th>SỐ LƯỢNG</th>
            <th>ĐƠN GIÁ (VNĐ)</th>
            <th>THÀNH TIỀN</th>
        </tr>
        <?php foreach ($chitietnhaps as $chitietnhap) : ?>
        <tr>
            <td><?php echo $chitietnhap['b']['TENSP']; ?></td>
            <td><?php echo $chitietnhap['b']['DONVITINH']; ?></td>
            <td><?php echo $chitietnhap['a']['SLNHAP']; ?></td>
            <td><?php echo
                CakeNumber::currency($chitietnhap['a']['DONGIANHAP'],'', array('thousands'=> '.',  'decimals' => ',',))
            ; ?></td>
            <td><?php echo
                CakeNumber::currency($chitietnhap['a']['SLNHAP'] * $chitietnhap['a']['DONGIANHAP'],'', array('thousands'=> '.',  'decimals' => ',',))
                ; ?></td>
        </tr>
        <?php endforeach; ?>
    </table>
    <br>
    <div style="margin-left: 3em; font-size: 1.25em">
    <?php
/*    echo "<p>Tổng tiền trước thuế : " . $tt['0']['0']['TongTien'] . " VNĐ</p>";
    $thue = $tt['0']['0']['TongTien'] * $hoadonnhap['HoaDonNhap']['THUENHAP'] / 100;
    echo "<p>Thuế : " . $hoadonnhap['HoaDonNhap']['THUENHAP'] . "%" . " | Tiền thuế : "
        . $thue . " VNĐ</p>";
    $sauthue = $tt['0']['0']['TongTien'] + $thue;
    echo "<p>Tổng tiền sau thuế : " . $sauthue . " VNĐ</p><br>";*/
        echo "<p>Tổng tiền trước thuế : " . CakeNumber::currency($tongtien,'', array('thousands'=> '.',  'decimals' => ',',)) . " VNĐ</p>";
        echo "<p>Thuế : " . $hoadonnhap['HoaDonNhap']['THUENHAP'] . "%" . " | Tiền thuế : "
            . CakeNumber::currency($tienthue,'', array('thousands'=> '.',  'decimals' => ',',)) . " VNĐ</p>";
        echo "<p>Tổng tiền sau thuế : " . CakeNumber::currency($tiensauthue,'', array('thousands'=> '.',  'decimals' => ',',)) . " VNĐ</p><br>";
    ?>
    </div>
    <br>

    <div id="ct" style="float: right; margin-right: 10em">
        <h3><b>BÊN BÁN</b></h3>
        <h6>(Kí tên)</h6>
    </div>
    <div id="nv" style="float: left; margin-left: 10em">
        <h3><b>BÊN NHẬP</b></h3>
        <h6>(Kí tên)</h6>
        <br><br><br>

        <h4><?php echo $tennv['0']['NhanVien']['TENNV']; ?></h4>
    </div>
</div>
